home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Cursor;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.Scrollbar;
- import java.awt.event.AdjustmentEvent;
- import java.awt.event.AdjustmentListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
-
- public class StarsText2 extends Applet implements Runnable, AdjustmentListener, MouseListener {
- private Thread thread;
- private Image backImage;
- private Image buffer;
- // $FF: renamed from: b java.awt.Graphics
- private Graphics field_0;
- private boolean loaded;
- private boolean move = true;
- // $FF: renamed from: on boolean
- private boolean field_1 = true;
- private boolean firstime = true;
- private boolean isBackImage = false;
- private boolean paintable = false;
- private boolean zoomable = true;
- private int text_height;
- private int current_height;
- private int height_step;
- private int height_step2;
- private int he_init;
- private int n_pas;
- private int letter_width;
- private int letter_width_100;
- private int letter_ascent;
- private int letter_ascent_100;
- // $FF: renamed from: wi int
- private int field_2;
- // $FF: renamed from: he int
- private int field_3;
- private int wiBack;
- private int heBack;
- private int pause;
- private int number;
- // $FF: renamed from: X int[]
- private int[] field_4;
- // $FF: renamed from: Y int[]
- private int[] field_5;
- private int[] step;
- private int decx;
- private int decy;
- // $FF: renamed from: x2 int
- private int field_6;
- // $FF: renamed from: y2 int
- private int field_7;
- // $FF: renamed from: x int
- private int field_8;
- // $FF: renamed from: y int
- private int field_9;
- private int x_init;
- private int y_init;
- private int n_p;
- private int decX;
- // $FF: renamed from: l int
- private int field_10;
- private int[] index;
- private int n_text;
- private int step_mean;
- private String letter;
- private String backImageName;
- private String text;
- private String big_text;
- private Color starColor;
- private Color backColor;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_11;
- private Scrollbar scroll;
- private int pause_init;
- private boolean isScrollbar;
- private String statusBarText;
- private AudioClip sound;
- private AudioClip clicSound;
- private AudioClip enterSound;
- private boolean loopSound;
- private String link;
- private FontMetrics fm2;
- private String enterText;
- private boolean isEnterTextEnabled;
- private int wiEnterText;
- private int enterTextHeight;
- private Color enterTextColor;
- private Font bufferFont;
- private Font textFont;
-
- public String getAppletInfo() {
- return "Name: StarsText2\r\nAuthor: Taiji Software\r\n";
- }
-
- public StarsText2() {
- this.move = true;
- this.pause = 20;
- this.number = 100;
- this.text_height = 10;
- this.height_step = 2;
- this.height_step2 = 2;
- ((Component)this).addMouseListener(this);
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var9) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- this.scroll = new Scrollbar(1, 30, 1, 0, 60);
- this.scroll.addAdjustmentListener(this);
- if (this.isScrollbar) {
- ((Container)this).setLayout(new BorderLayout());
- ((Container)this).add("East", this.scroll);
- }
-
- if (this.sound != null) {
- if (this.loopSound) {
- this.sound.loop();
- return;
- }
-
- this.sound.play();
- }
-
- }
-
- public void getParameters() {
- this.field_2 = ((Component)this).getSize().width;
- if (this.isScrollbar) {
- this.field_2 -= this.scroll.getSize().width;
- }
-
- this.field_3 = ((Component)this).getSize().height;
- String s = ((Applet)this).getParameter("pause");
- if (s != null) {
- this.pause = Integer.parseInt(s);
- }
-
- this.pause_init = this.pause;
- s = ((Applet)this).getParameter("number");
- if (s != null) {
- this.number = Integer.parseInt(s);
- }
-
- this.big_text = ((Applet)this).getParameter("text");
- s = ((Applet)this).getParameter("text_height");
- if (s != null) {
- this.text_height = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("step_mean");
- if (s != null) {
- this.step_mean = Integer.parseInt(s);
- } else {
- this.step_mean = this.field_2 / 10;
- }
-
- s = ((Applet)this).getParameter("height_step");
- if (s != null) {
- this.height_step = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("height_step2");
- if (s != null) {
- this.height_step2 = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("height_init");
- if (s != null) {
- this.he_init = Integer.parseInt(s);
- } else {
- this.he_init = this.field_3;
- }
-
- s = ((Applet)this).getParameter("scrollbar");
- if (s != null) {
- this.isScrollbar = new Boolean(s);
- } else {
- this.isScrollbar = false;
- }
-
- this.starColor = this.getColor("star_color");
- if (this.starColor == null) {
- this.starColor = Color.white;
- }
-
- this.backColor = this.getColor("background_color");
- if (this.backColor == null) {
- this.backColor = Color.black;
- }
-
- ((Component)this).setBackground(this.backColor);
- this.backImageName = ((Applet)this).getParameter("background_image");
- if (this.backImageName != null) {
- this.isBackImage = true;
- }
-
- this.statusBarText = ((Applet)this).getParameter("status_bar_text");
- s = ((Applet)this).getParameter("sound_name");
- if (s != null) {
- this.sound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("loop_sound");
- if (s != null) {
- if (s.equals("yes")) {
- this.loopSound = true;
- } else {
- this.loopSound = false;
- }
- }
-
- s = ((Applet)this).getParameter("clic_sound_name");
- if (s != null) {
- this.clicSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("enter_sound_name");
- if (s != null) {
- this.enterSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- this.link = ((Applet)this).getParameter("link");
- this.enterText = ((Applet)this).getParameter("enter_text");
- s = ((Applet)this).getParameter("enter_text_height");
- if (s != null) {
- this.enterTextHeight = Integer.parseInt(s);
- }
-
- this.enterTextColor = this.getColor("enter_text_color");
- if (this.enterTextColor == null) {
- this.enterTextColor = Color.white;
- }
-
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public void adjustmentValueChanged(AdjustmentEvent e) {
- int v = this.scroll.getValue() - 30;
- float f = (float)v;
- if (f < 0.0F) {
- f = 1.0F / f;
- }
-
- this.pause = (int)((float)this.pause_init * f);
- if (this.pause < 5) {
- this.pause = 5;
- }
-
- }
-
- public final void refonte(int h) {
- this.field_0.setFont(new Font("TimesRoman", 1, h));
- this.field_11 = this.field_0.getFontMetrics();
- }
-
- public final void nextLetter() {
- this.letter = this.text.substring(this.field_10, this.field_10 + 1);
- this.refonte(this.text_height);
- this.letter_width_100 = this.field_11.stringWidth(this.letter);
- this.letter_ascent_100 = this.field_11.getAscent();
- this.current_height = this.he_init;
- this.refonte(this.current_height);
- this.letter_width = this.field_11.stringWidth(this.letter);
- this.letter_ascent = this.field_11.getMaxAscent();
- this.field_6 = (this.letter_width_100 - this.letter_width) / 2;
- this.field_7 = (this.text_height - this.current_height) / 2 + this.letter_ascent - this.text_height;
- this.x_init = (this.field_2 - this.field_11.stringWidth(this.letter)) / 2 - this.field_6;
- this.y_init = (this.field_3 + this.field_11.getMaxAscent() - this.field_11.getMaxDescent()) / 2 - this.field_7;
- this.n_p = 0;
- }
-
- public final void nextText() {
- ++this.n_text;
- if (this.n_text > this.index.length) {
- this.text = this.big_text.substring(0, this.index[0]);
- this.n_text = 0;
- } else if (this.n_text == this.index.length) {
- this.text = this.big_text.substring(this.index[this.n_text - 1] + 1);
- } else {
- this.text = this.big_text.substring(this.index[this.n_text - 1] + 1, this.index[this.n_text]);
- }
-
- this.refonte(this.text_height);
- this.decx = (this.field_2 - this.field_11.stringWidth(this.text)) / 2;
- this.decy = (this.field_3 + this.field_11.getMaxAscent() - this.field_11.getMaxDescent()) / 2;
- this.field_10 = 0;
- this.decX = 0;
- }
-
- public final void paint(Graphics g) {
- if (this.paintable) {
- this.field_0.clearRect(0, 0, this.field_2, this.field_3);
- if (this.isBackImage & this.loaded) {
- this.field_0.drawImage(this.backImage, (this.field_2 - this.wiBack) / 2, (this.field_3 - this.heBack) / 2, this);
- }
-
- if (this.zoomable) {
- this.refonte(this.current_height);
- this.letter_width = this.field_11.stringWidth(this.letter);
- this.letter_ascent = this.field_11.getMaxAscent();
- this.n_pas = (this.he_init - this.text_height) / this.height_step;
- if (this.n_p > this.n_pas) {
- this.n_p = this.n_pas;
- }
-
- this.field_8 = this.x_init - this.n_p * (this.x_init - (this.decX + this.decx)) / this.n_pas;
- this.field_9 = this.y_init - this.n_p * (this.y_init - this.decy) / this.n_pas;
- this.field_6 = (this.letter_width_100 - this.letter_width) / 2;
- this.field_7 = (this.text_height - this.current_height) / 2 + this.letter_ascent - this.text_height;
- this.field_0.drawString(this.letter, this.field_8 + this.field_6, this.field_9 + this.field_7);
- }
-
- if (!this.zoomable) {
- this.refonte(this.current_height);
- this.letter_width = this.field_11.stringWidth(this.text);
- this.letter_ascent = this.field_11.getMaxAscent();
- this.field_8 = (this.letter_width_100 - this.letter_width) / 2;
- this.field_9 = (this.text_height - this.current_height) / 2 + this.letter_ascent - this.text_height;
- this.field_0.drawString(this.text.substring(0, this.field_10), this.decx + this.field_8, this.decy + this.field_9);
- this.current_height -= this.height_step2;
- if (this.current_height <= this.height_step2) {
- if (this.index != null) {
- this.nextText();
- }
-
- this.refonte(this.text_height);
- this.field_10 = 0;
- this.decX = 0;
- this.nextLetter();
- this.zoomable = true;
- }
- }
-
- if (this.field_10 != 0 & this.zoomable) {
- this.refonte(this.text_height);
- this.field_0.drawString(this.text.substring(0, this.field_10), this.decx, this.decy);
- }
-
- if (this.zoomable) {
- this.current_height -= this.height_step;
- ++this.n_p;
- }
-
- if (this.current_height <= this.text_height & this.zoomable) {
- if (this.field_10 == this.text.length() - 1) {
- this.zoomable = false;
- ++this.field_10;
- this.current_height = this.text_height;
- this.refonte(this.text_height);
- this.letter_width_100 = this.field_11.stringWidth(this.text);
- this.letter_ascent_100 = this.field_11.getAscent();
- } else {
- this.decX += this.letter_width_100;
- ++this.field_10;
- this.nextLetter();
- }
- }
-
- for(int i = 0; i < this.number; ++i) {
- this.field_0.drawRect(this.field_4[i], this.field_5[i], 1, 1);
- }
-
- if (this.isEnterTextEnabled) {
- this.bufferFont = this.field_0.getFont();
- this.field_0.setColor(this.enterTextColor);
- this.field_0.setFont(this.textFont);
- this.field_0.drawString(this.enterText, (this.field_2 - this.wiEnterText) / 2, this.field_3 / 2);
- this.field_0.setColor(this.starColor);
- this.field_0.setFont(this.bufferFont);
- }
-
- g.drawImage(this.buffer, 0, 0, this);
- }
-
- }
-
- public final void update(Graphics g) {
- this.paint(g);
- }
-
- public void start() {
- if (this.thread == null) {
- this.move = true;
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- }
-
- public void stop() {
- if (this.thread != null) {
- this.move = false;
- this.thread = null;
- }
-
- if (this.sound != null) {
- this.sound.stop();
- }
-
- }
-
- public void run() {
- if (this.firstime) {
- if (this.isBackImage) {
- MediaTracker tracker = new MediaTracker(this);
- this.backImage = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.backImageName);
- tracker.addImage(this.backImage, 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- } catch (InterruptedException var6) {
- this.stop();
- }
-
- if (!this.loaded) {
- this.stop();
- return;
- }
- }
-
- if (this.isBackImage) {
- this.wiBack = this.backImage.getWidth(this);
- this.heBack = this.backImage.getHeight(this);
- }
-
- this.buffer = ((Component)this).createImage(this.field_2, this.field_3);
- this.field_0 = this.buffer.getGraphics();
- String fontName = ((Applet)this).getParameter("enter_text_font");
- if (fontName == null) {
- fontName = "TimesRoman";
- }
-
- int style = 1;
- String s = ((Applet)this).getParameter("enter_text_style");
- if (s != null) {
- if (s.equals("bold")) {
- style = 1;
- } else if (s.equals("italic")) {
- style = 2;
- } else if (s.equals("bold_italic")) {
- style = 3;
- } else {
- style = 0;
- }
- }
-
- this.textFont = new Font(fontName, style, this.enterTextHeight);
- this.field_0.setFont(new Font("TimesRoman", 1, this.enterTextHeight));
- this.fm2 = this.field_0.getFontMetrics();
- if (this.enterText != null) {
- this.wiEnterText = this.fm2.stringWidth(this.enterText);
- }
-
- this.field_0.setColor(this.starColor);
- this.paintable = true;
- this.firstime = false;
- }
-
- this.field_4 = new int[this.number];
- this.field_5 = new int[this.number];
- this.step = new int[this.number];
-
- for(int i = 0; i < this.number; ++i) {
- this.field_4[i] = (int)((double)this.field_2 * Math.random());
- this.field_5[i] = (int)((double)this.field_3 * Math.random());
- this.step[i] = (int)((double)this.step_mean * Math.random()) + 1;
- }
-
- int c = 0;
-
- int m;
- for(m = 0; (c = this.big_text.indexOf("#", c)) != -1; ++m) {
- ++c;
- }
-
- if (m != 0) {
- this.index = new int[m];
-
- for(int var14 = 0; (c = this.big_text.indexOf("#", c)) != -1; ++var14) {
- this.index[var14] = c++;
- }
-
- this.text = this.big_text.substring(0, this.index[0]);
- this.n_text = 0;
- } else {
- this.text = this.big_text;
- }
-
- this.refonte(this.text_height);
- this.decx = (this.field_2 - this.field_11.stringWidth(this.text)) / 2;
- this.decy = (this.field_3 + this.field_11.getMaxAscent() - this.field_11.getMaxDescent()) / 2;
- this.field_10 = 0;
- this.decX = 0;
- this.nextLetter();
-
- while(this.move) {
- while(this.field_1) {
- for(int i = 0; i < this.number; ++i) {
- int[] var10000 = this.field_4;
- var10000[i] += this.step[i];
- if (this.field_4[i] > this.field_2) {
- this.field_4[i] = 0;
- }
- }
-
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.pause);
- } catch (InterruptedException var7) {
- this.stop();
- }
-
- if (!this.field_1) {
- }
- }
-
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var5) {
- this.stop();
- }
- }
-
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- if (this.enterText != null) {
- this.isEnterTextEnabled = true;
- ((Component)this).repaint();
- }
-
- if (this.statusBarText != null) {
- ((Applet)this).showStatus(this.statusBarText);
- }
-
- if (this.enterSound != null) {
- this.enterSound.play();
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(12));
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- if (this.isEnterTextEnabled) {
- this.isEnterTextEnabled = false;
- ((Component)this).repaint();
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(0));
- }
-
- }
-
- public void mousePressed(MouseEvent e) {
- if (this.clicSound != null) {
- this.clicSound.play();
- }
-
- if (this.link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(this.link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- }
-
- public void mouseReleased(MouseEvent e) {
- }
- }
-